home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Resources / Online / Term / Extras / HydraCom / hydracom-source.lha / hydracom.h < prev    next >
C/C++ Source or Header  |  1995-08-18  |  9KB  |  286 lines

  1. /*=============================================================================
  2.  
  3.                               HydraCom Version 1.00
  4.  
  5.                          A sample implementation of the
  6.                    HYDRA Bi-Directional File Transfer Protocol
  7.  
  8.                              HydraCom was written by
  9.                    Arjen G. Lentz, LENTZ SOFTWARE-DEVELOPMENT
  10.                   COPYRIGHT (C) 1991-1993; ALL RIGHTS RESERVED
  11.  
  12.                        The HYDRA protocol was designed by
  13.                  Arjen G. Lentz, LENTZ SOFTWARE-DEVELOPMENT and
  14.                              Joaquim H. Homrighausen
  15.                   COPYRIGHT (C) 1991-1993; ALL RIGHTS RESERVED
  16.  
  17.  
  18.   Revision history:
  19.   06 Sep 1991 - (AGL) First tryout
  20.   .. ... .... - Internal development
  21.   11 Jan 1993 - HydraCom version 1.00, Hydra revision 001 (01 Dec 1992)
  22.  
  23.  
  24.   For complete details of the Hydra and HydraCom licensing restrictions,
  25.   please refer to the license agreements which are published in their entirety
  26.   in HYDRACOM.C and LICENSE.DOC, and also contained in the documentation file
  27.   HYDRACOM.DOC
  28.  
  29.   Use of this file is subject to the restrictions contained in the Hydra and
  30.   HydraCom licensing agreements. If you do not find the text of this agreement
  31.   in any of the aforementioned files, or if you do not have these files, you
  32.   should immediately contact LENTZ SOFTWARE-DEVELOPMENT and/or Joaquim
  33.   Homrighausen at one of the addresses listed below. In no event should you
  34.   proceed to use this file without having accepted the terms of the Hydra and
  35.   HydraCom licensing agreements, or such other agreement as you are able to
  36.   reach with LENTZ SOFTWARE-DEVELOMENT and Joaquim Homrighausen.
  37.  
  38.  
  39.   Hydra protocol design and HydraCom driver:         Hydra protocol design:
  40.   Arjen G. Lentz                                     Joaquim H. Homrighausen
  41.   LENTZ SOFTWARE-DEVELOPMENT                         389, route d'Arlon
  42.   Langegracht 7B                                     L-8011 Strassen
  43.   3811 BT  Amersfoort                                Luxembourg
  44.   The Netherlands
  45.   FidoNet 2:283/512, AINEX-BBS +31-33-633916         FidoNet 2:270/17
  46.   arjen_lentz@f512.n283.z2.fidonet.org               joho@ae.lu
  47.  
  48.   Please feel free to contact us at any time to share your comments about our
  49.   software and/or licensing policies.
  50.  
  51. =============================================================================*/
  52.  
  53. #ifndef WIN_AGL
  54. #define WIN_AGL 0        /* set to 1 for AGL's MS-DOS/AtariST window package */
  55. #endif
  56.  
  57. #include <stdio.h>
  58. #include <stdlib.h>
  59. #include <stdarg.h>
  60. #include <string.h>
  61. #include <ctype.h>
  62. #ifdef AMIGA
  63. #define byte foo234234
  64. #include <dos.h>
  65. #undef byte
  66. #else
  67. #include <dos.h>
  68. #endif    /* AMIGA */
  69. #include <time.h>
  70. #include <sys/stat.h>
  71. /*#include <process.h>*/    /* OLSEN */
  72. /*#include <signal.h>*/        /* OLSEN */
  73. #if WIN_AGL
  74. #include "window.h"     /* AGL's window library */
  75. #endif
  76. #ifdef AMIGA
  77. #include <fcntl.h>        /* OLSEN */
  78. #else
  79. #include <conio.h>      /* MS-DOS Turbo/Borland C(++) console stuff */
  80. #endif
  81. #include "2types.h"
  82. #include "hydra.h"
  83.  
  84. #ifdef __MSDOS__
  85. #define inteli(x) (x)
  86. #define intell(x) (x)
  87. #endif
  88. #if !WIN_AGL
  89. #define Esc   0x01b
  90. #define Alt_B 0x130
  91. #define Alt_C 0x12e
  92. #define Alt_E 0x112
  93. #define Alt_H 0x123
  94. #define Alt_X 0x12D
  95. #define PgUp  0x149
  96. #define PgDn  0x151
  97. #endif
  98.  
  99. #ifdef AMIGA
  100. #include "amiga.h"
  101. #define intell(x) (((x & 0x000000FF) << 24) | ((x & 0x0000FF00) << 8) | ((x & 0x00FF0000) >> 8) | ((x & 0xFF000000) >> 24))
  102. #endif    /* AMIGA */
  103.  
  104. #define PRGNAME "HydraCom"
  105. #define LOGID   "HCom"
  106. #define VERSION "1.00"
  107. #ifdef __MSDOS__
  108. #  define HC_OS  "PC"
  109. #else /*!MSDOS*/
  110. #  ifdef __OS2__
  111. #    define HC_OS  "OS/2"
  112. #  else /*!OS2*/
  113. #    ifdef __TOS__
  114. #      define HC_OS  "ST"
  115. #    endif /*TOS*/
  116. #  endif /*OS2*/
  117. #endif /*MSDOS*/
  118.  
  119. #ifdef AMIGA
  120. #define HC_OS "AMIGA"
  121. #endif    /* AMIGA */
  122.  
  123.  
  124. #ifdef AMIGA        /* OLSEN */
  125. #define PATHLEN 256
  126. #define MAXARGS 256
  127. #else
  128. #define PATHLEN 90
  129. #define MAXARGS 50
  130. #endif    /* AMIGA */
  131.  
  132. #define DENY_ALL   0x0000
  133. #define DENY_RDWR  0x0010
  134. #define DENY_WRITE 0x0020
  135. #define DENY_READ  0x0030
  136. #define DENY_NONE  0x0040
  137.  
  138. #ifdef MAIN
  139. #define global
  140. #else
  141. #define global extern
  142. #endif
  143.  
  144. global  char     ourname[PATHLEN];
  145. global  char     work[256],
  146.                  buffer[256];
  147. global  char     device[256];    /* OLSEN */
  148. global  int      pri;        /* OLSEN */
  149. global  int      port;
  150. #ifdef AMIGA
  151. global  long     cur_speed;
  152. global  long     com_speed;
  153. #else
  154. global  word     cur_speed;
  155. global  word     com_speed;
  156. #endif
  157. global  boolean  parity;
  158. global  boolean  noinit;
  159. global  boolean  nocarrier;
  160. global  boolean  dropdtr;
  161. global  int      flowflags;
  162. global  int      dcdmask;
  163. #ifdef AMIGA
  164. global  boolean  quiet;
  165. #endif
  166. global  boolean  nobell;
  167. global  boolean  mailer;
  168. global  boolean  nooriginator;
  169. global  boolean  hdxsession;
  170. global  long     hydra_txwindow,
  171.                  hydra_rxwindow;
  172. global  char    **av;
  173. global  int      loglevel;
  174. global  FILE    *logfp;
  175. global  char    *result;
  176. global  char    *download;
  177. #ifdef AMIGA
  178. global  char     single_file[32];
  179. #else
  180. global  char     single_file[20];
  181. #endif    /* AMIGA */
  182. global  boolean  single_done;
  183. global  boolean  noresume;
  184. global  boolean  nostamp;
  185. global  dword    hydra_options;
  186. global  int      opustask;
  187. global  char    *opuslog;
  188. global  boolean  didsome;
  189. #if WIN_AGL
  190. global  WIN_IDX  file_win,
  191.                  log_win,
  192.                  remote_win,
  193.                  local_win;
  194. global  boolean  log_first;
  195. #else
  196. global  void    *term_scr;
  197. global  int      term_x,   term_y,
  198.                  file_x,   file_y,
  199.                            log_y,
  200.                  remote_x, remote_y,
  201.                  local_x,  local_y;
  202. #endif
  203.  
  204. #define CHAT_TIMEOUT 60
  205. global  word     chatfill;
  206. global  long     chattimer,
  207.                  lasttimer;
  208.  
  209.  
  210. #ifdef __PROTO__
  211. # define        PROTO(s) s
  212. #else
  213. # define        PROTO(s) ()
  214. #endif
  215.  
  216.  
  217. /* hydracom.c */
  218. void endprog     PROTO((int errcode ));
  219. int  config      PROTO((int argc , char *argv []));
  220. void init        PROTO((void ));
  221. int  batch_hydra PROTO((char *filespec, char *alias ));
  222. void hydracom    PROTO((void ));
  223.  
  224. /* fmisc.c */
  225. void     unique_name PROTO((char *pathname ));
  226. char    *xfer_init   PROTO((char *fname , long fsize , long ftime ));
  227. boolean  xfer_bad    PROTO((void ));
  228. char    *xfer_okay   PROTO((void ));
  229. void    xfer_del     PROTO((void ));
  230.  
  231. /* misc.c */
  232. int   keyabort     PROTO((void ));
  233. void  rem_chat     PROTO((byte *data, word len ));
  234. int   parse        PROTO((char *string ));
  235. void  splitpath    PROTO((char *filepath , char *path , char *file ));
  236. void  mergepath    PROTO((char *filepath , char *path , char *file ));
  237. int   fexist       PROTO((char *filename ));
  238. void  any_key      PROTO((void ));
  239. int   get_key      PROTO((void ));
  240. int   get_str      PROTO((char *prompt , char *s , int maxlen ));
  241. void  resultlog    PROTO((boolean xmit , char *fname , long bytes , long xfertime ));
  242. char *h_revdate    PROTO((long revstamp ));
  243. void  message      PROTO((int level , char *fmt , ...));
  244. void  cprint       PROTO((char *fmt , ...));
  245. void  hydra_gotoxy PROTO((int x, int y ));
  246. void  hydra_printf PROTO((char *fmt, ...));
  247. void  hydra_clreol PROTO((void ));
  248.  
  249. /* dos_file.c */
  250. void  dos_sharecheck PROTO((void ));
  251. int   dos_open       PROTO((char *pathname , byte create ));
  252. int   dos_sopen      PROTO((char *pathname , byte create ));
  253. int   dos_sappend    PROTO((char *pathname , byte create ));
  254. int   dos_close      PROTO((int handle ));
  255. int   dos_lock       PROTO((int handle , long offset , long len ));
  256. int   dos_unlock     PROTO((int handle , long offset , long len ));
  257. long  dos_seek       PROTO((int handle , long offset , int fromwhere ));
  258. long  dos_tell       PROTO((int handle ));
  259. int   dos_read       PROTO((int handle , void *buf , word len ));
  260. int   dos_write      PROTO((int handle , void *buf , word len ));
  261. FILE *sfopen         PROTO((char *name, char *mode, int shareflag));
  262.  
  263. /* syspc.c */
  264. void  dtr_out      PROTO((byte flag ));
  265. void  com_flow     PROTO((byte flags ));
  266. void  com_setspeed PROTO((word speed ));
  267. void  com_putblock PROTO((byte *s , word len ));
  268. void  sys_init     PROTO((void ));
  269. void  sys_reset    PROTO((void ));
  270. void  sys_idle     PROTO((void ));
  271. int   com_outfull  PROTO((void ));
  272. int   carrier      PROTO((void ));
  273. void  com_flush    PROTO((void ));
  274. void  com_putbyte  PROTO((byte c ));
  275. void  com_purge    PROTO((void ));
  276. void  com_dump     PROTO((void ));
  277. int   com_getbyte  PROTO((void ));
  278. void  setstamp     PROTO((char *name , long tim ));
  279. long  freespace    PROTO((char *drivepath ));
  280. char *ffirst       PROTO((char *filespec ));
  281. char *fnext        PROTO((void ));
  282.  
  283. #undef PROTO
  284.  
  285. /* end of hydracom.h */
  286.